<!--#include file="../nav/admin_top.php" -->
<div class="titleDiv">
	<div class="titleCaption">
		<span class="captionSpan">信息维护</span>
		<span class="totalSpan"> <label id="captionNum"></label> </span>
	</div>
</div>
 
<div class="menuBg">
	<a class="menuAdd" href="{url::build('admin_pen','add')}">添加信息</a>
  <div style="clear:both"></div>
</div>
<div style="margin:10px auto">
	搜索：
	<select id="pentype_id" class="textBox">
		<option value="">-- 所有信息分类 --</option>
		<?PHP
		foreach($pentypes as $v){ 
			echo '<option value="'.$v['id'].'">'.$v['parentmap'].'</option>';
		}
		?> 
	</select>
  
	<select id="publishs" class="textBox">
		<option value="">-- 所有发布状态 --</option>
		<option value="1">正常发布</option> 
		<option value="0">暂停发布</option> 
	</select> 
	<input type="text" maxlength="12" id="keywords" class="searchs" /> 
	<input type="button"  onclick="fnSearchs()" value="查询"  />  	
</div> 
<div id="grids"></div> 
<script type="text/javascript">
var url_list = '/admin_pen/index_list'; 
var url_modify = '/admin_pen/modify'; 
var url_del = '/admin_pen/del'; 
$().ready(function(){
	o2js.build('ymprompt'); 
	o2js.build('o2grid');
	showLoading();
	grids = new o2Grid({
		bind:'grids', 
		url:url_list,
		singleSelect:true,
		imgpath:'/misc/vendors/o2js/o2grid/image',
		cols:[
			{index:'id',mapping:'a.id', name:'序号', width:40,sortable:false, func:function(val,row_index,column_name,json,R){
				 return  '<span title="ID：'+json.id+'" >'+((R.page - 1)*R.rowNum + (row_index+1))+'</span>';
			}}, 
			{index:'pentype_name',mapping:'b.name', name:'信息分类', width:150,func:function(val,row_index,column_name,json,R){
					return val;
				}
			},
			{index:'title',mapping:'a.title', name:'标题', width:190,func:function(val,row_index,column_name,json,R){
					return val;
				}
			},
			{index:'create_date',mapping:'a.create_date', name:'创建日期', width:140,func:function(val,row_index,column_name,json,R){
					return val;
				}
			},
			{index:'create_user_id',mapping:'a.create_user_id', name:'创建者', width:120,func:function(val,row_index,column_name,json,R){ 
						return json.create_username; 
				}
			},
			{index:'publishs',mapping:'a.publishs', name:'发布状态', width:80,func:function(val,row_index,column_name,json,R){
					var s = '';
					if(val == '1'){ 
						s= '<span class="green">正常发布</span>';
					}else{
						s= '<span class="red">暂停发布</span>';
					}
					return s;
			}
			},
			{index:'id',mapping:'a.id', name:'操作'	, width:170,sortable:false,func:function(val,row_index,column_name,json,R){
					return   ' <a href="javascript:void(0)" onclick="fnView('+json.id+')" style="color: "  ><img src="/misc/images/icos/finished.gif" />  预览</a> ' + ' <a href="'+url_modify+'?id='+json.id+'" style="color: "  ><img src="/misc/images/edit.gif" />  编辑</a> '+ ' <a href="javascript:void(0)" onclick="fnDel('+json.id+')" ><img src="/misc/images/del.gif" /> 删除</a> ';
				}
			}
		],
		endfunc:function(obj){
			 
		}
	});
	fnSearchs();	 
	$('#keywords').keypress(function(e){
		if(e.keyCode==13||e.keyCode==10){
			fnSearchs();
		}
	}); 
	
});   
function fnSearchs(){
	grids.setBaseParams({
		keywords:encodeURIComponent($('#keywords').val()),
		pentype_id:$('#pentype_id').val(),
		publishs:$('#publishs').val()
	}); 
	grids.load(1); 
}

/*  */
function fnView(id){ 
	ymPrompt.close();
	ymPrompt.win({
		title:'内容预览',
		fixPosition:true,
		maxBtn:true,
		width: 900, 
		height: 500,
		iframe:{
			src:'/admin_pen/view?id='+id
		}
	}); 	
}

/* 删除 */
function fnDel(NId){
	fnConfirm({
		str:'确认删除本行数据?',
		func_true:function(){
			$('button').attr('disabled','disabled');
			$.post(
				url_del,
				{
					idarr:JSON.encode([NId])
				},
				function(e){
					var ok = errorHandler(e);
					if(ok && ok.success=='1'){
						//window.location.reload();
						grids.reload();
					}
					$('button').attr('disabled','');
				}
			);
		}
	}); 
}
</script>
<!--#include file="../nav/admin_bottom.php" -->